param (
    $version
)

# 获取脚本所在目标
$path = Split-Path -Parent $MyInvocation.MyCommand.Definition

# 切换工作目录到脚本目录
Set-Location -Path $path

Write-Output "设置版本号$($version)"
mvn versions:set -DnewVersion="$($version)" -DgenerateBackupPoms=false

Write-Output "正在修改变量中的版本号"
$content = Get-Content -path "$($path)\pom.xml"
$content = $content -replace '\<virens\.version\>([\w\.]+)\</virens\.version\>', "<virens.version>$($version)</virens.version>"

Set-Content -Path "$($path)\pom.xml" -Value $content

Write-Output "重新打包"
mvn clean package

Write-Output "上传版本"
mvn deploy -P release

exit